package com.composite;

import java.util.ArrayList;
import java.util.List;

public class College extends OrganizationComponent{

    // 这里存放的是系
    List<OrganizationComponent> organizationComponents = new ArrayList<>();

    // 构造器
    public College(String name, String des) {
        super(name, des);
    }

    // 重写add

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    // print方法，就是输出University包含的学院
    @Override
    protected void print() {
        System.out.println("-------------" + getName() + "-------------");
        // 遍历organizationComponents
        for (OrganizationComponent organizationComponent : organizationComponents){
            organizationComponent.print();
        }
    }
}
